import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Dimensions,
  ActivityIndicator
} from 'react-native';

var Util = {
  windowSize: {
    width: Dimensions.get("window").width,
    height: Dimensions.get("window").height
  },
  // 基于fetch的get方法，只负责下载数据
  getRequest: function (url, success, failure) {
    fetch(url)
        .then((response) => response.json())
        .then((responseData) => success(responseData))
        .catch((error) => failure(error))
  },
  // loading
  loading: <ActivityIndicator style={{marginTop: 200}}/>
}

module.exports = Util;